<?php use_stylesheet('tasks.css') ?>
<?php use_javascript('toggle.js') ?>
<!--h1>Tasks List</h1-->
<table width="100%" border="0" cellpadding="0" cellspacing="0" background="/images/mainpage-sliced_16.jpg">
  <tr>
    <td width="20" height="40">&nbsp;</td>
    <td class="style5" style="border-right:solid 1px #FFFFFF;">View Tasks {<?php echo $sf_user->getAttribute('selectedProject')?>}</td>
  </tr>
</table>
<div id="tasks">
  <?php 
    if (!$sf_user->getAttribute('selectedProject')->getProjectid())
	{
	  echo "<p class=\"errormessage\">There is no Project to show Task Info from.</p>";
	}
    elseif (count($milestones) == 0)
	{
	  echo "<p class=\"errormessage\">There are no tasks associated with any milestones of this Project.</p>";
	}
    foreach ($milestones as $milestone): ?>
    <div>
      <div class="milestone">                
      
        <h4 style="background-color:#FFCC66" ><a href='#' id='toggleLink'></a>Tasks of Milestone [<a href="<?php echo url_for('milestone/show?milestoneid='.$milestone->getMilestoneid())?>"><?php echo $milestone ?></a>]</h4>
      </div>
      <div id="toggle">
      <?php include_partial('task/list', array('tasks' => $milestone->getTasks(sfConfig::get('app_max_tasks_to_show')))) ?> 
      
      <?php if (($count = $milestone->countTasks() - sfConfig::get('app_max_tasks_to_show')) > 0): ?>
        <div class="more_tasks">
          and <a href="<?php echo url_for('milestone/show?milestoneid='.$milestone->getMilestoneid())?>"><?php echo $count ?></a>
          more...
        </div>
      <?php endif; ?>

     <hr/>
     </div>
    </div>
  <?php endforeach; ?>
</div>
<?php 
if (!$sf_user->getAttribute('selectedProject')->getProjectid() and $sf_user->hasGroup('manager'))
{
?>
<div class="regulartext"><a href="<?php echo url_for('project/new') ?>">Create New Project</a></div>
<?php
}
elseif ($sf_user->hasPermission("task.create"))
{ ?>
<div class="regulartext"><a href="<?php echo url_for('task/new') ?>">Create New Task</a></div>
<?php
}
?>
<hr/>